<?php

class GeneratePassword
{
	public function CreatePassword()
	{
		$password = "";
		$length = 8;
		$possible = "23456789abcdfghjkmnpqrstuvwxyzABCDFGHJKLMNPQRSTUVWXYZ";
		$maxlength = strlen($possible);
	  
		if ($length > $maxlength) 
		{
			$length = $maxlength;
	 	}
		
	    $i = 0; 
	    
	    while ($i < $length) 
		{ 
	      	$char = substr($possible, mt_rand(0, $maxlength-1), 1);
	        
	      	if (!strstr($password, $char)) 
			{ 
				$password .= $char;
	        	
	        	$i++;
	      	}
	
	    }
	    
	    return $password;
	  }
}